import request from "@/api/request";

/**
 * 获取分页列表
 * @param params 参数
 */
export function getPage(params: SearchListParams) {
  return request({
    url: "/log/login/log/page",
    method: "get",
    params: params,
  });
}

/**
 * 获取列表
 * @param params 参数
 */
export function getList(params: SearchListParams) {
  return request({
    url: "/log/login/log/list",
    method: "get",
    params: params,
  });
}

/**
 * 获取详情
 * @param params 参数
 */
export function getInfo(params: string) {
  return request({
    url: "/log/login/log/" + params,
    method: "get"
  });
}

/**
 * 新增
 * @param params 参数
 */
export function saveInfo(params: DataInfo) {
  return request({
    url: "/log/login/log/save",
    method: "post",
    data: params,
  });
}

/**
 * 修改
 * @param params 参数
 */
export function editInfo(params: DataInfo) {
  return request({
    url: "/log/login/log/update",
    method: "post",
    data: params,
  });
}

/**
 * 删除
 * @param params 参数
 */
export function deleteInfo(params: string | string[]) {
  return request({
    url: "/log/login/log/remove/" + params.toString(),
    method: "get"
  });
}

export interface SearchListParams {
    pageNum: number;
    pageSize: number;
    username: string;
    nickName: string
    loginTime: string;
    loginStatus: number | null;
}

export interface DataInfo {
    id: string | null;
    userId: string;
    username: string;
    nickName: string;
    loginTime: string;
    loginIp: string;
    loginLocation: string;
    deviceInfo: string;
    loginStatus: number | null;
    failureReason: string;
    token: string;
    requestParam: string;
    userAgent: string;
    logoutTime: string;
    loginChannel: number | null;
}

export interface TableData {
    id: string;
    username: string;
    loginTime: string;
    loginIp: string;
    deviceInfo: string;
    loginStatus: number;
    failureReason: string;
    userAgent: string;
    logoutTime: string;
}